import { LabelGetCommand } from "../command/label.command"
import labelEventEnum from "../enum/labelEvent.enum"

export default {
  getData: (sdk, allFunc, dependencies) => {
    allFunc.addBinding(LabelGetCommand, async () => allFunc.makeLabelData(...(await dependencies.getDependencies())))
    sdk.addCommandCreator({ namespace: "Label", name: "getData", args: [] }, () => new LabelGetCommand())
  },
  Event: sdk => {
    sdk.addEnumToInterface({ namespace: "Label", name: "Event", values: labelEventEnum })
  },
  onEvent: (sdk, exportOBJ, allFunc, dependencies) => {
    dependencies.getDependencies().then(([n, r, a, s, i]) => {
      const data = () => [allFunc.makeLabelData(n, a, r, i)]
      n.onChanged(o => {
        s.currentMode === exportOBJ.Viewmode.Floorplan && sdk.broadcast(labelEventEnum.POSITION_UPDATED, data, o)
      })
    })
  }
}
